package com.ruoyi.boss.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.boss.domain.PhoneTempBlacklist;
import com.ruoyi.boss.service.IPhoneTempBlacklistService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 手机号临时黑名单Controller
 * 
 * @author rui
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/TempBlacklist")
public class PhoneTempBlacklistController extends BaseController
{
    @Autowired
    private IPhoneTempBlacklistService phoneTempBlacklistService;

    /**
     * 查询手机号临时黑名单列表
     */
    @RequiresPermissions("boss:TempBlacklist:list")
    @GetMapping("/list")
    public TableDataInfo list(PhoneTempBlacklist phoneTempBlacklist)
    {
        startPage();
        List<PhoneTempBlacklist> list = phoneTempBlacklistService.selectPhoneTempBlacklistList(phoneTempBlacklist);
        return getDataTable(list);
    }

    /**
     * 导出手机号临时黑名单列表
     */
    @RequiresPermissions("boss:TempBlacklist:export")
    @Log(title = "手机号临时黑名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PhoneTempBlacklist phoneTempBlacklist)
    {
        List<PhoneTempBlacklist> list = phoneTempBlacklistService.selectPhoneTempBlacklistList(phoneTempBlacklist);
        ExcelUtil<PhoneTempBlacklist> util = new ExcelUtil<PhoneTempBlacklist>(PhoneTempBlacklist.class);
        util.exportExcel(response, list, "手机号临时黑名单数据");
    }

    /**
     * 获取手机号临时黑名单详细信息
     */
    @RequiresPermissions("boss:TempBlacklist:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(phoneTempBlacklistService.selectPhoneTempBlacklistById(id));
    }

    /**
     * 新增手机号临时黑名单
     */
    @RequiresPermissions("boss:TempBlacklist:add")
    @Log(title = "手机号临时黑名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PhoneTempBlacklist phoneTempBlacklist)
    {
        return toAjax(phoneTempBlacklistService.insertPhoneTempBlacklist(phoneTempBlacklist));
    }

    /**
     * 修改手机号临时黑名单
     */
    @RequiresPermissions("boss:TempBlacklist:edit")
    @Log(title = "手机号临时黑名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PhoneTempBlacklist phoneTempBlacklist)
    {
        return toAjax(phoneTempBlacklistService.updatePhoneTempBlacklist(phoneTempBlacklist));
    }

    /**
     * 删除手机号临时黑名单
     */
    @RequiresPermissions("boss:TempBlacklist:remove")
    @Log(title = "手机号临时黑名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(phoneTempBlacklistService.deletePhoneTempBlacklistByIds(ids));
    }
}
